package cn.dnui_jpf902.dnuifood_16110100902.model;

import cn.dnui_jpf902.dnuifood_16110100902.bean.ResultBean;
import cn.dnui_jpf902.dnuifood_16110100902.bean.UserBean;
import cn.dnui_jpf902.dnuifood_16110100902.iface.UserIfice;
import cn.dnui_jpf902.dnuifood_16110100902.listener.onRetrofitListener;
import cn.dnui_jpf902.dnuifood_16110100902.service.UserService;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by 姜鹏飞 on 2018/10/15.
 */


public abstract class UserModel extends BaseModel implements UserIfice {
   private UserService service;
   @Override
   public void login(String username, String userpass,
                     final onRetrofitListener listener) {
               service =retrofit.create(UserService.class);
       Call<UserBean> call=service
               .doLogin(username,userpass);
       bindCallback(call,listener,1);
//     call.enqueue(new Callback<UserBean>() {
//           @Override
//           public void onResponse(Call<UserBean> call, Response<UserBean> response) {
//               if(response.body()!=null)
//                   listener.onSuccess(response.body());
//
//               else
//                   listener.onFalure("解析错误！");
//
//           }
//           @Override
//           public void onFailure(Call<UserBean> call, Throwable t) {
//                              listener.onFalure(t.toString());
//           }
//       });

                   }
    @Override
    public void register(String username, String userpass, String mobilenum, String address, String comment, onRetrofitListener listener) {
        service = retrofit.create(UserService.class);
        Call<ResultBean> call;
        call = service.doRegist(username,userpass,
                mobilenum,address,comment);
        bindCallback(call,listener,1);


    }



}